import { useEffect } from "react"

function useEvent(ref, event, callback) {
  useEffect(() => {
    const target = ref.current // 将ref.current的值复制到变量target中
    target.addEventListener(event, callback)
    return () => target.removeEventListener(event, callback) // 使用变量target来移除事件监听器
  }, [ref, event, callback])
}

export default useEvent
